import 'package:kk/model/home_model.dart';
import 'dart:async';
import 'dart:convert';
import 'package:http/http.dart' as http;

class HomeDao {
  static Future<HomeModel?> fetch() async {
    final response = await http
        .get("https://www.devio.org/io/flutter_app/json/home_page.json");

    if (response.statusCode == 200) {
      Utf8Decoder utf8decoder = Utf8Decoder(); //fix中文乱码
      var result = json.decode(utf8decoder.convert(response.bodyBytes));
      return HomeModel.fromJson(result);
    } else {
      throw Exception("Failed to load home_page.json");
    }
  }
}
